package com.luna.servlets;

import com.luna.service.MessageService;
import com.luna.serviceImpl.MessageServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(
        name = "ReadMessages",
        urlPatterns = "/ReadMessages"
)
public class ReadMessages extends HttpServlet {

    public ReadMessages() {}

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        MessageService messageService = new MessageServiceImpl();
        messageService.readMessages(Integer.parseInt(req.getParameter("user_id")));
    }
}
